/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Sony
 */
public class DataAcess {
    private static Connection connection;

    public static Connection ConnectionDatabase() throws ClassNotFoundException, SQLException{
        if(connection == null || connection.isClosed()){
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String url = "jdbc:sqlserver://25.89.149.252;databaseName=SocialNetwork";
            String user = "sa";
            String pw = "123456";
            connection = DriverManager.getConnection(url, user, pw);
        }
        return connection; 
    }
}
